[PATCH 1/2] Add notmuch_database_flush method

2012-10-18 Thread Adrien Bustany
This method explicitly flushes the pending modifications to disk. It is
useful if your program has various threads, each with a read only DB and
one writer thread with a read/write DB. In that case, you most likely
want the writer to sync the changes to disk so that the readers can see
them, without having to close and reopen the database completely.
---
 lib/database.cc | 18 ++
 lib/notmuch.h   |  4 
 2 files changed, 22 insertions(+)

diff --git a/lib/database.cc b/lib/database.cc
index 761dc1a..1b680ab 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -745,6 +745,24 @@ notmuch_database_open (const char *path,
 return status;
 }

+notmuch_status_t
+notmuch_database_flush(notmuch_database_t *notmuch)
+{
+notmuch_status_t status = NOTMUCH_STATUS_SUCCESS;
+
+try {
+   if (notmuch->xapian_db != NULL &&
+   notmuch->mode == NOTMUCH_DATABASE_MODE_READ_WRITE)
+   (static_cast  
(notmuch->xapian_db))->flush ();
+} catch (const Xapian::Error ) {
+   fprintf(stderr, "A Xapian exception occured flushing the database: 
%s\n",
+   error.get_msg().c_str());
+   status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
+}
+
+return status;
+}
+
 void
 notmuch_database_close (notmuch_database_t *notmuch)
 {
diff --git a/lib/notmuch.h b/lib/notmuch.h
index 3633bed..aef5c56 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -201,6 +201,10 @@ notmuch_database_open (const char *path,
   notmuch_database_mode_t mode,
   notmuch_database_t **database);

+/* Flushes all the pending modifications to the database to disk. */
+notmuch_status_t
+notmuch_database_flush (notmuch_database_t *database);
+
 /* Close the given notmuch database.
  *
  * After notmuch_database_close has been called, calls to other
-- 
1.7.11.7



[PATCH 1/2] Add notmuch_database_flush method

2012-10-18 Thread Adrien Bustany
Le 17/10/2012 18:53, Ethan Glasser-Camp a ?crit :
> Adrien Bustany  writes:
>
>> This method explicitly flushes the pending modifications to disk. It is
>> useful if your program has various threads, each with a read only DB and
>> one writer thread with a read/write DB. In that case, you most likely
>> want the writer to sync the changes to disk so that the readers can see
>> them, without having to close and reopen the database completely.
>
> These patches are pretty straightforward. But to conform to notmuch style..
>
>> +notmuch_status_t
>> +notmuch_database_flush(notmuch_database_t *notmuch)
>> +{
>> +notmuch_status_t status = NOTMUCH_STATUS_SUCCESS;
>
> Indent is 4 spaces. (You have tabs here, which are 8 spaces, according
> to devel/STYLE.)
>
>> +try {
>> +if (notmuch->xapian_db != NULL &&
>
> if should be more indented than try. (So when you pull try back to 4
> spaces, leave if at 8 spaces.)

Sorry about that... I think I copied the style from 
notmuch_database_close, but my editor was set to have 4-space tabs, so I 
got confused. I'll send a fixed version of the patches.

>
>> +notmuch->mode == NOTMUCH_DATABASE_MODE_READ_WRITE)
>> +(static_cast  
>> (notmuch->xapian_db))->flush ();
>
> This line is 90 characters, and will remain at 86 once you indent using
> the in-house style. I'm not sure if it's worth reformatting.
> notmuch_database_close calls flush() using exactly the same 86-character
> line. I'd say "don't make it worse", but personally I think breaking
> this line might be worse.
>

Yes, I also think breaking this line will not make things prettier :-/

> Ethan
>

Thanks for the review!

Adrien


[PATCH 1/2] Add notmuch_database_flush method

2012-10-17 Thread Ethan Glasser-Camp
Adrien Bustany  writes:

> This method explicitly flushes the pending modifications to disk. It is
> useful if your program has various threads, each with a read only DB and
> one writer thread with a read/write DB. In that case, you most likely
> want the writer to sync the changes to disk so that the readers can see
> them, without having to close and reopen the database completely.

These patches are pretty straightforward. But to conform to notmuch style..

> +notmuch_status_t
> +notmuch_database_flush(notmuch_database_t *notmuch)
> +{
> + notmuch_status_t status = NOTMUCH_STATUS_SUCCESS;

Indent is 4 spaces. (You have tabs here, which are 8 spaces, according
to devel/STYLE.)

> + try {
> + if (notmuch->xapian_db != NULL &&

if should be more indented than try. (So when you pull try back to 4
spaces, leave if at 8 spaces.)

> + notmuch->mode == NOTMUCH_DATABASE_MODE_READ_WRITE)
> + (static_cast  
> (notmuch->xapian_db))->flush ();

This line is 90 characters, and will remain at 86 once you indent using
the in-house style. I'm not sure if it's worth reformatting.
notmuch_database_close calls flush() using exactly the same 86-character
line. I'd say "don't make it worse", but personally I think breaking
this line might be worse.

Ethan


Re: [PATCH 1/2] Add notmuch_database_flush method

2012-10-17 Thread Ethan Glasser-Camp
Adrien Bustany adr...@bustany.org writes:

 This method explicitly flushes the pending modifications to disk. It is
 useful if your program has various threads, each with a read only DB and
 one writer thread with a read/write DB. In that case, you most likely
 want the writer to sync the changes to disk so that the readers can see
 them, without having to close and reopen the database completely.

These patches are pretty straightforward. But to conform to notmuch style..

 +notmuch_status_t
 +notmuch_database_flush(notmuch_database_t *notmuch)
 +{
 + notmuch_status_t status = NOTMUCH_STATUS_SUCCESS;

Indent is 4 spaces. (You have tabs here, which are 8 spaces, according
to devel/STYLE.)

 + try {
 + if (notmuch-xapian_db != NULL 

if should be more indented than try. (So when you pull try back to 4
spaces, leave if at 8 spaces.)

 + notmuch-mode == NOTMUCH_DATABASE_MODE_READ_WRITE)
 + (static_cast Xapian::WritableDatabase * 
 (notmuch-xapian_db))-flush ();

This line is 90 characters, and will remain at 86 once you indent using
the in-house style. I'm not sure if it's worth reformatting.
notmuch_database_close calls flush() using exactly the same 86-character
line. I'd say don't make it worse, but personally I think breaking
this line might be worse.

Ethan
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 1/2] Add notmuch_database_flush method

2012-10-17 Thread Adrien Bustany

Le 17/10/2012 18:53, Ethan Glasser-Camp a écrit :

Adrien Bustany adr...@bustany.org writes:


This method explicitly flushes the pending modifications to disk. It is
useful if your program has various threads, each with a read only DB and
one writer thread with a read/write DB. In that case, you most likely
want the writer to sync the changes to disk so that the readers can see
them, without having to close and reopen the database completely.


These patches are pretty straightforward. But to conform to notmuch style..


+notmuch_status_t
+notmuch_database_flush(notmuch_database_t *notmuch)
+{
+   notmuch_status_t status = NOTMUCH_STATUS_SUCCESS;


Indent is 4 spaces. (You have tabs here, which are 8 spaces, according
to devel/STYLE.)


+   try {
+   if (notmuch-xapian_db != NULL 


if should be more indented than try. (So when you pull try back to 4
spaces, leave if at 8 spaces.)


Sorry about that... I think I copied the style from 
notmuch_database_close, but my editor was set to have 4-space tabs, so I 
got confused. I'll send a fixed version of the patches.





+   notmuch-mode == NOTMUCH_DATABASE_MODE_READ_WRITE)
+   (static_cast Xapian::WritableDatabase * 
(notmuch-xapian_db))-flush ();


This line is 90 characters, and will remain at 86 once you indent using
the in-house style. I'm not sure if it's worth reformatting.
notmuch_database_close calls flush() using exactly the same 86-character
line. I'd say don't make it worse, but personally I think breaking
this line might be worse.



Yes, I also think breaking this line will not make things prettier :-/


Ethan



Thanks for the review!

Adrien
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 1/2] Add notmuch_database_flush method

2012-10-17 Thread Adrien Bustany
This method explicitly flushes the pending modifications to disk. It is
useful if your program has various threads, each with a read only DB and
one writer thread with a read/write DB. In that case, you most likely
want the writer to sync the changes to disk so that the readers can see
them, without having to close and reopen the database completely.
---
 lib/database.cc | 18 ++
 lib/notmuch.h   |  4 
 2 files changed, 22 insertions(+)

diff --git a/lib/database.cc b/lib/database.cc
index 761dc1a..1b680ab 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -745,6 +745,24 @@ notmuch_database_open (const char *path,
 return status;
 }
 
+notmuch_status_t
+notmuch_database_flush(notmuch_database_t *notmuch)
+{
+notmuch_status_t status = NOTMUCH_STATUS_SUCCESS;
+
+try {
+   if (notmuch-xapian_db != NULL 
+   notmuch-mode == NOTMUCH_DATABASE_MODE_READ_WRITE)
+   (static_cast Xapian::WritableDatabase * 
(notmuch-xapian_db))-flush ();
+} catch (const Xapian::Error error) {
+   fprintf(stderr, A Xapian exception occured flushing the database: 
%s\n,
+   error.get_msg().c_str());
+   status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
+}
+
+return status;
+}
+
 void
 notmuch_database_close (notmuch_database_t *notmuch)
 {
diff --git a/lib/notmuch.h b/lib/notmuch.h
index 3633bed..aef5c56 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -201,6 +201,10 @@ notmuch_database_open (const char *path,
   notmuch_database_mode_t mode,
   notmuch_database_t **database);
 
+/* Flushes all the pending modifications to the database to disk. */
+notmuch_status_t
+notmuch_database_flush (notmuch_database_t *database);
+
 /* Close the given notmuch database.
  *
  * After notmuch_database_close has been called, calls to other
-- 
1.7.11.7

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 1/2] Add notmuch_database_flush method

2012-07-19 Thread Adrien Bustany
This method explicitly flushes the pending modifications to disk. It is
useful if your program has various threads, each with a read only DB and
one writer thread with a read/write DB. In that case, you most likely
want the writer to sync the changes to disk so that the readers can see
them, without having to close and reopen the database completely.
---
 lib/database.cc |   18 ++
 lib/notmuch.h   |4 
 2 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/lib/database.cc b/lib/database.cc
index 761dc1a..55bcd17 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -745,6 +745,24 @@ notmuch_database_open (const char *path,
 return status;
 }

+notmuch_status_t
+notmuch_database_flush(notmuch_database_t *notmuch)
+{
+   notmuch_status_t status = NOTMUCH_STATUS_SUCCESS;
+
+   try {
+   if (notmuch->xapian_db != NULL &&
+   notmuch->mode == NOTMUCH_DATABASE_MODE_READ_WRITE)
+   (static_cast  
(notmuch->xapian_db))->flush ();
+   } catch (const Xapian::Error ) {
+   fprintf(stderr, "A Xapian exception occured flushing the database: 
%s\n",
+   error.get_msg().c_str());
+   status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
+   }
+
+   return status;
+}
+
 void
 notmuch_database_close (notmuch_database_t *notmuch)
 {
diff --git a/lib/notmuch.h b/lib/notmuch.h
index 3633bed..aef5c56 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -201,6 +201,10 @@ notmuch_database_open (const char *path,
   notmuch_database_mode_t mode,
   notmuch_database_t **database);

+/* Flushes all the pending modifications to the database to disk. */
+notmuch_status_t
+notmuch_database_flush (notmuch_database_t *database);
+
 /* Close the given notmuch database.
  *
  * After notmuch_database_close has been called, calls to other
-- 
1.7.7.6



[PATCH 1/2] Add notmuch_database_flush method

2012-07-19 Thread Adrien Bustany
This method explicitly flushes the pending modifications to disk. It is
useful if your program has various threads, each with a read only DB and
one writer thread with a read/write DB. In that case, you most likely
want the writer to sync the changes to disk so that the readers can see
them, without having to close and reopen the database completely.
---
 lib/database.cc |   18 ++
 lib/notmuch.h   |4 
 2 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/lib/database.cc b/lib/database.cc
index 761dc1a..55bcd17 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -745,6 +745,24 @@ notmuch_database_open (const char *path,
 return status;
 }
 
+notmuch_status_t
+notmuch_database_flush(notmuch_database_t *notmuch)
+{
+   notmuch_status_t status = NOTMUCH_STATUS_SUCCESS;
+
+   try {
+   if (notmuch-xapian_db != NULL 
+   notmuch-mode == NOTMUCH_DATABASE_MODE_READ_WRITE)
+   (static_cast Xapian::WritableDatabase * 
(notmuch-xapian_db))-flush ();
+   } catch (const Xapian::Error error) {
+   fprintf(stderr, A Xapian exception occured flushing the database: 
%s\n,
+   error.get_msg().c_str());
+   status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
+   }
+
+   return status;
+}
+
 void
 notmuch_database_close (notmuch_database_t *notmuch)
 {
diff --git a/lib/notmuch.h b/lib/notmuch.h
index 3633bed..aef5c56 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -201,6 +201,10 @@ notmuch_database_open (const char *path,
   notmuch_database_mode_t mode,
   notmuch_database_t **database);
 
+/* Flushes all the pending modifications to the database to disk. */
+notmuch_status_t
+notmuch_database_flush (notmuch_database_t *database);
+
 /* Close the given notmuch database.
  *
  * After notmuch_database_close has been called, calls to other
-- 
1.7.7.6

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch